package gwtgaetools.client.ui;

import gwtgaetools.client.ItemManager;
import gwtgaetools.client.listeners.Listener;

import com.google.gwt.user.client.ui.RadioButton;
public class SmartRadioButton<T> extends RadioButton implements Listener<ItemManager<T>> {

	public SmartRadioButton(ItemManager<String> group, ItemManager<T> t, boolean b) {
		super("");
		group.registerListener(new Listener<ItemManager<String>>() {

			@Override
			public void observe(ItemManager<String> t) {
				setName(t.getItem());
			}
			
		});
		t.registerListener(this, b);
	}
	
	public SmartRadioButton(ItemManager<String> g, ItemManager<T> t){
		this(g, t, true);
	}

	@Override
	public void observe(ItemManager<T> t) {
		if (t.getItem()!=null)
			setText(t.getItem().toString());
	}
}